//
//  SAMarketListCell.m
//  YunFu
//
//  Created by Bager on 2018/9/12.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "SAMarketListCell.h"

@implementation SAMarketListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setViews];
    }
    
    return self;
}

- (void)setViews
{
    [self addSubview:self.img];
    [self addSubview:self.name];
}

- (UIImageView *)img
{
    if (!_img)
    {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 150)];
        _img.contentMode = UIViewContentModeScaleAspectFill;
        _img.layer.masksToBounds = YES;
        [_img setImage:[UIImage imageNamed:@"yf1-sc2"]];
    }
    return _img;
}

- (UILabel *)name
{
    if (!_name)
    {
        _name = [[UILabel alloc] initWithFrame:self.img.frame];
        _name.font = [UIFont systemFontOfSize:20 weight:2];
        _name.adjustsFontSizeToFitWidth = YES;
        _name.text = @"现代百货";
        _name.textColor = [UIColor whiteColor];
        _name.textAlignment = NSTextAlignmentCenter;
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.colors = @[(__bridge id)[UIColor colorWithWhite:0 alpha:0.1].CGColor, (__bridge id)[UIColor colorWithWhite:0 alpha:0.6].CGColor, (__bridge id)[UIColor colorWithWhite:0 alpha:0.1].CGColor];
        gradientLayer.locations = @[@0.0, @0.5, @1.0];
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(0, 1.0);
        gradientLayer.frame = self.name.frame;
        [_name.layer addSublayer:gradientLayer];
    }
    return _name;
}

@end
